var touserid="",todepartid="",tocomid="";
function Publish_Data(tableid) {
	var date=new Date();
	var buffer = new StringBuffer();
	buffer.append('<div class="publish border-bottom">');
		if(tableid=="5")
		{
		buffer.append('<div class="position" style="padding-left:0px; margin-top:0px;"><div class="inner border-bottom" style="width:'+(swidth-20)+'px;"><input id="noticetitle" type="text" placeholder="填写公告标题" /></div></div>');
		}
		if(tableid=="4")
		{
		buffer.append('<div class="position" style="float:left; height:10px; background-color:#f3f3f3;"></div>');
		buffer.append('<div id="examinetype_tool" class="position border-top-bottom" style="padding-left:20px;"><div class="inner" style="width:'+(swidth-20)+'px;"><div class="icon"><img src="img/examinetype.png"/></div><div class="address"><div class="long" style="width:25%;">审批类型</div><div class="long" style="width:75%;"><input id="examinetype" type="text" value="普通审批" val="1" readonly="readonly"/></div></div><div class="arrow"><img src="img/arrow.png"/></div></div></div>');
		buffer.append('<div class="position border-bottom" style="float:left; height:15px; background-color:#f3f3f3;"></div>');
		
		//请假单
		buffer.append('<div id="leavesheet" class="hidden">');
		buffer.append('<div id="leavetype_tool" class="position" style="padding-left:0px;"><div class="inner border-bottom" style="width:'+(swidth-20)+'px;"><div class="icon"><img src="img/jiatype.png"/></div><div class="address"><div class="long" style="width:25%;">请假类型</div><div class="long" style="width:75%;"><input id="leave_type" type="text" value="事假" readonly="readonly"/></div></div><div class="arrow"><img src="img/arrow.png"/></div></div></div>');
		buffer.append('<div id="begindate_tool" class="position date" style="padding-left:0px;"><div class="inner border-bottom" style="width:'+(swidth-20)+'px;"><div class="icon"><img src="img/timer.png"/></div><div class="address"><div class="long" style="width:25%;">开始时间</div><div class="long" style="width:75%;"><input id="leave_begindate" type="text" value="" readonly="readonly" placeholder="必填" onchange="Check_Date1(this)"/></div></div><div class="arrow"><img src="img/arrow.png"/></div></div></div>');
		buffer.append('<div id="enddate_tool" class="position date" style="padding-left:0px;"><div class="inner border-bottom" style="width:'+(swidth-20)+'px;"><div class="icon"><img src="img/timer.png"/></div><div class="address"><div class="long" style="width:25%;">结束时间</div><div class="long" style="width:75%;"><input id="leave_enddate" type="text" value="" readonly="readonly" placeholder="必填" onchange="Check_Date1(this)"/></div></div><div class="arrow"><img src="img/arrow.png"/></div></div></div>');
		buffer.append('<div id="leavelong_tool" class="position" style="padding-left:0px;"><div class="inner border-bottom" style="width:'+(swidth-20)+'px;"><div class="icon"><img src="img/timelong.png"/></div><div id="begindate" class="address"><div id="" class="long" style="width:auto">请假时长</div>');
		buffer.append('<div id="day_tool" class="long" style="width:auto"><div><select id="leave_day"><option>0</option><option selected="selected">1</option><option>2</option><option>3</option><option>4</option><option>5</option><option>6</option><option>7</option><option>8</option><option>9</option><option>10</option><option>11</option><option>12</option><option>13</option><option>14</option><option>15</option><option>16</option><option>17</option><option>18</option><option>19</option><option>20</option></select></div><div>天</div></div>');
		buffer.append('<div id="hour_tool" class="long" style="width:auto"><div><select id="leave_hour"><option>0</option><option>1</option><option>2</option><option>3</option><option>4</option><option>5</option><option>6</option><option>7</option><option>8</option><option>9</option><option>10</option><option>11</option><option>12</option><option>13</option><option>14</option><option>15</option><option>16</option><option>17</option><option>18</option><option>19</option><option>20</option><option>21</option><option>22</option><option>23</option></select></div><div>小时</div></div>');
		buffer.append('<div id="minute_tool" class="long" style="width:auto"><div><select id="leave_minute"><option>0</option><option>1</option><option>2</option><option>3</option><option>4</option><option>5</option><option>6</option><option>7</option><option>8</option><option>9</option><option>10</option><option>11</option><option>12</option><option>13</option><option>14</option><option>15</option><option>16</option><option>17</option><option>18</option><option>19</option><option>20</option><option>21</option><option>22</option><option>23</option><option>24</option><option>25</option><option>26</option><option>27</option><option>28</option><option>29</option><option>30</option><option>31</option><option>32</option><option>33</option><option>34</option><option>35</option><option>36</option><option>37</option><option>38</option><option>39</option><option>40</option><option>41</option><option>42</option><option>43</option><option>44</option><option>45</option><option>46</option><option>47</option><option>48</option><option>49</option><option>50</option><option>51</option><option>52</option><option>53</option><option>54</option><option>55</option><option>56</option><option>57</option><option>58</option><option>59</option></select></div><div>分钟</div></div>');
		buffer.append('</div><div class="arrow"><img src="img/arrow.png"/></div></div></div>');
		buffer.append('</div>');
		//请假单
		
		//加班单
		buffer.append('<div id="overtimesheet" class="hidden">');
		buffer.append('<div id="obegindate_tool" class="position date" style="padding-left:0px;"><div class="inner border-bottom" style="width:'+(swidth-20)+'px;"><div class="icon"><img src="img/timer.png"/></div><div class="address"><div class="long" style="width:25%;">开始时间</div><div class="long" style="width:75%;"><input id="overtime_begindate" type="text" value="" readonly="readonly" placeholder="必填" onchange="Check_Date3(this)"/></div></div><div class="arrow"><img src="img/arrow.png"/></div></div></div>');
		buffer.append('<div id="oenddate_tool" class="position date" style="padding-left:0px;"><div class="inner border-bottom" style="width:'+(swidth-20)+'px;"><div class="icon"><img src="img/timer.png"/></div><div class="address"><div class="long" style="width:25%;">结束时间</div><div class="long" style="width:75%;"><input id="overtime_enddate" type="text" value="" readonly="readonly" placeholder="必填" onchange="Check_Date3(this)"/></div></div><div class="arrow"><img src="img/arrow.png"/></div></div></div>');
		buffer.append('<div id="overtimelong_tool" class="position" style="padding-left:0px;"><div class="inner border-bottom" style="width:'+(swidth-20)+'px;"><div class="icon"><img src="img/timelong.png"/></div><div class="address"><div id="" class="long" style="width:auto">加班时长</div>');
		buffer.append('<div id="oday_tool" class="long" style="width:auto"><div><select id="overtime_day"><option selected="selected">0</option><option>1</option><option>2</option><option>3</option><option>4</option><option>5</option><option>6</option><option>7</option><option>8</option><option>9</option><option>10</option><option>11</option><option>12</option><option>13</option><option>14</option><option>15</option><option>16</option><option>17</option><option>18</option><option>19</option><option>20</option></select></div><div>天</div></div>');
		buffer.append('<div id="ohour_tool" class="long" style="width:auto"><div><select id="overtime_hour"><option>0</option><option>1</option><option>2</option><option>3</option><option selected="selected">4</option><option>5</option><option>6</option><option>7</option><option>8</option><option>9</option><option>10</option><option>11</option><option>12</option><option>13</option><option>14</option><option>15</option><option>16</option><option>17</option><option>18</option><option>19</option><option>20</option><option>21</option><option>22</option><option>23</option></select></div><div>小时</div></div>');
		buffer.append('<div id="ominute_tool" class="long" style="width:auto"><div><select id="overtime_minute"><option>0</option><option>1</option><option>2</option><option>3</option><option>4</option><option>5</option><option>6</option><option>7</option><option>8</option><option>9</option><option>10</option><option>11</option><option>12</option><option>13</option><option>14</option><option>15</option><option>16</option><option>17</option><option>18</option><option>19</option><option>20</option><option>21</option><option>22</option><option>23</option><option>24</option><option>25</option><option>26</option><option>27</option><option>28</option><option>29</option><option>30</option><option>31</option><option>32</option><option>33</option><option>34</option><option>35</option><option>36</option><option>37</option><option>38</option><option>39</option><option>40</option><option>41</option><option>42</option><option>43</option><option>44</option><option>45</option><option>46</option><option>47</option><option>48</option><option>49</option><option>50</option><option>51</option><option>52</option><option>53</option><option>54</option><option>55</option><option>56</option><option>57</option><option>58</option><option>59</option></select></div><div>分钟</div></div>');
		buffer.append('</div><div class="arrow"><img src="img/arrow.png"/></div></div></div>');
		buffer.append('</div>');
		//加班单
		
		//报销单
		buffer.append('<div id="reimbursesheet" class="hidden">');
		buffer.append('<div class="position" style="padding-left:0px;"><div class="inner border-bottom" style="width:'+(swidth-20)+'px;"><div class="icon"><img src="img/jiatype.png"/></div><div id="leavetype" class="address"><div class="long" style="width:25%;">报销项</div><div class="long" style="width:75%;"><input id="reimburse_name" placeholder="必填" type="text" value="" /></div></div><div class="arrow"></div></div></div>');
		buffer.append('<div class="position" style="padding-left:0px;"><div class="inner border-bottom" style="width:'+(swidth-20)+'px;"><div class="icon"><img src="img/jinbi.png"/></div><div id="begindate" class="address"><div class="long" style="width:25%;">报销金额</div><div class="long" style="width:75%;"><input id="reimburse_money" placeholder="必填" type="tel" value="" /></div></div><div class="arrow"></div></div></div>');
		buffer.append('</div>');
		//报销单
		
		//差旅单
		buffer.append('<div id="travelsheet" class="hidden">');
		buffer.append('<div id="traveluser_tool" class="position users" show="1" touserid="'+User.ID+'" todepartid="" tocomid="" style="padding-left:0px;"><div class="inner border-bottom" style="width:'+(swidth-20)+'px;"><div class="icon"><img src="img/user.png"/></div><div id="leavetype" class="address"><div class="long" style="width:25%;">出差人</div><div class="long" style="width:75%;"><input id="traveluser" placeholder="" type="text" value="'+User.RealName+'" readonly="readonly"/></div></div><div class="arrow"><img src="img/arrow.png"/></div></div></div>');
		buffer.append('<div class="position" style="padding-left:0px;"><div class="inner border-bottom" style="width:'+(swidth-20)+'px;"><div class="icon"><img src="img/jinbi.png"/></div><div class="address"><div class="long" style="width:25%;">预算</div><div class="long" style="width:75%;"><input id="examine_money" placeholder="选填" type="tel" value="" /></div></div></div></div>');
		buffer.append('<div class="position" style="padding-left:0px;"><div class="inner border-bottom" style="width:'+(swidth-20)+'px;"><div class="icon"><img src="img/jinbi.png"/></div><div class="address"><div class="long" style="width:25%;">预支</div><div class="long" style="width:75%;"><input id="examine_advance" placeholder="选填" type="tel" value="" /></div></div></div></div>');
		buffer.append('<div class="position" style="padding-left:0px;"><div class="inner border-bottom" style="width:'+(swidth-20)+'px;"><div class="icon"><img src="img/home.png"/></div><div class="address"><div class="long" style="width:25%;">出发地</div><div class="long" style="width:75%;"><input id="travel_beginplace" placeholder="必填" type="text" value="" onfocus="ScrollTop()"/></div></div></div></div>');
		buffer.append('<div id="travelbegindate_tool" class="position" style="padding-left:0px;"><div class="inner border-bottom" style="width:'+(swidth-20)+'px;"><div class="icon"><img src="img/timer.png"/></div><div class="address"><div class="long" style="width:25%;">出发时间</div><div class="long" style="width:75%;"><input id="travel_begindate" placeholder="必填" type="text" value="" readonly="readonly" onchange="Check_Date2(this)"/></div></div><div class="arrow"><img src="img/arrow.png"/></div></div></div>');
		buffer.append('<div class="position" style="padding-left:0px;"><div class="inner border-bottom" style="width:'+(swidth-20)+'px;"><div class="icon"><img src="img/dest.png"/></div><div class="address"><div class="long" style="width:25%;">目的地</div><div class="long" style="width:75%;"><input id="travel_endplace" placeholder="必填" type="text" value="" onfocus="ScrollTop()"/></div></div></div></div>');
		//buffer.append('<div id="travelenddate_tool" class="position" style="padding-left:0px;"><div class="inner border-bottom" style="width:'+(swidth-20)+'px;"><div class="icon"><img src="img/timer.png"/></div><div class="address"><div class="long" style="width:25%;">到达时间</div><div class="long" style="width:75%;"><input id="travel_enddate" placeholder="必填" type="text" value="" readonly="readonly" onchange="Check_Date2(this)"/></div></div><div class="arrow"><img src="img/arrow.png"/></div></div></div>');
		//buffer.append('<div id="traveltraffic_tool" class="position" style="padding-left:0px;"><div class="inner border-bottom" style="width:'+(swidth-20)+'px;"><div class="icon"><img src="img/traffic.png"/></div><div class="address"><div class="long" style="width:25%;">交通工具</div><div class="long" style="width:75%;"><input id="travel_traffic" placeholder="必填" type="text" value="" readonly="readonly"/></div></div><div class="arrow"><img src="img/arrow.png"/></div></div></div>');
		//buffer.append('<div class="position" style="padding-left:0px;"><div class="inner border-bottom" style="width:'+(swidth-20)+'px;"><div class="icon"><img src="img/sunny.png"/></div><div class="address"><div class="long" style="width:25%;">住宿天数</div><div class="long" style="width:75%;"><input id="travel_day" placeholder="选填" type="text" value="" onfocus="ScrollTop()"/></div></div></div></div>');
		buffer.append('</div>');
		//差旅单
		
		
		//借款单
		buffer.append('<div id="borrowsheet" class="hidden">');
		buffer.append('<div class="position" style="padding-left:0px;"><div class="inner border-bottom" style="width:'+(swidth-20)+'px;"><div class="icon"><img src="img/user.png"/></div><div id="leavetype" class="address"><div class="long" style="width:25%;">借款人</div><div class="long" style="width:75%;"><input placeholder="" type="text" value="'+User.RealName+'" readonly="readonly"/></div></div></div></div>');
		buffer.append('<div class="position" style="padding-left:0px;"><div class="inner border-bottom" style="width:'+(swidth-20)+'px;"><div class="icon"><img src="img/jinbi.png"/></div><div id="begindate" class="address"><div class="long" style="width:25%;">借款金额</div><div class="long" style="width:75%;"><input id="borrow_money" placeholder="必填" type="tel" value="" /></div></div></div></div>');
		buffer.append('</div>');
		//借款单
		
		//外勤单
		buffer.append('<div id="outsidesheet" class="hidden">');
		//buffer.append('<div id="customer_tool" class="position" style="padding-left:0px;"><div class="inner border-bottom" style="width:'+(swidth-20)+'px;"><div class="icon"><img src="img/cust.png"/></div><div id="leavetype" class="address"><div class="long" style="width:25%;">拜访客户</div><div class="long" style="width:75%;"><input id="txt_customerid" placeholder="必填" type="text" value="" readonly="readonly"/></div></div><div class="arrow"><img src="img/arrow.png"/></div></div></div>');
		//buffer.append('<div class="position" style="padding-left:0px;"><div class="inner border-bottom" style="width:'+(swidth-20)+'px;"><div class="icon"><img src="img/user.png"/></div><div class="address"><div class="long" style="width:25%;">联系人</div><div class="long" style="width:75%;"><select id="txt_contactid" style="width:auto;"></select></div></div><div class="arrow"><img src="img/arrow.png"/></div></div></div>');
		//buffer.append('<div class="position" style="padding-left:0px;"><div class="inner border-bottom" style="width:'+(swidth-20)+'px;"><div class="icon"><img src="img/phone.png"/></div><div class="address"><div class="long" style="width:25%;">联系电话</div><div class="long" style="width:75%;"><input id="txt_mobile" placeholder="必填" type="text" value="" onfocus="ScrollTop()"/></div></div><div class="arrow"></div></div></div>');
		//buffer.append('<div class="position" style="padding-left:0px;"><div class="inner border-bottom" style="width:'+(swidth-20)+'px;"><div class="icon"><img src="img/dest.png"/></div><div class="address"><div class="long" style="width:25%;">拜访地址</div><div class="long" style="width:75%;"><input id="txt_address" placeholder="必填" type="text" value="" onfocus="ScrollTop()"/></div></div><div class="arrow"></div></div></div>');
		buffer.append('</div>');
		//外勤单
		
		}
		buffer.append('<div id="context" class="share_title" style="margin-top:10px;">日志内容：</div>');
		buffer.append('<textarea id="share_context" placeholder="填写'+Get_Model(parseInt(tableid))+'内容" onkeyup=Context_Change(this,"context",'+tableid+') onfocus="ScrollTop()"></textarea>');
		if(tableid=="2")
		{
		buffer.append('<div id="plans" class="share_title">明日计划：</div>');
		buffer.append('<textarea id="share_plans" placeholder="填写明日计划" onkeyup=Context_Change(this,"plans",'+tableid+')></textarea>');
		buffer.append('<div id="experience" class="share_title">心得体会：</div>');
		buffer.append('<textarea id="share_experience" placeholder="填写心得体会" onkeyup=Context_Change(this,"experience",'+tableid+')></textarea>');
		}
		buffer.append('<div class="addphoto border-bottom" style="width:'+(swidth-20)+'px;"><div id="img_src"><div id="addphoto" style="float:left"><img class="add" src="img/add-photo.png" style="width:'+(swidth-70)/4+'px;height:'+(swidth-70)/4+'px;" /><div class="imgload"></div></div></div></div>');
		if(tableid<=5)
		{
		buffer.append('<div id="currposition" class="position"><div class="icon"><img src="img/position.png"/></div><div id="addresses" lat="" lng="" class="address">所在位置</div><div class="arrow"><img src="img/arrow.png"/></div></div>');
		}
		buffer.append('<div class="position border-top-bottom" style="float:left; height:15px; background-color:#f3f3f3;"></div>');
		if(tableid=="1")
		{
		buffer.append('<div class="position users" show="2" touserid="" todepartid="" tocomid="'+comid+'" style="padding-left:0px;"><div class="inner border-bottom" style="width:'+(swidth-20)+'px;"><div class="icon"><img src="img/client.png"/></div><div id="sendrange" class="address"><div class="long" style="width:25%;">发送给谁</div><div class="long" style="width:75%;"><input id="traveluser" placeholder="" type="text" value="全公司" readonly="readonly"/></div></div><div class="arrow"><img src="img/arrow.png"/></div></div></div>');
		buffer.append('<div id="vote_tool" hasvote="false" class="position border-bottom" style="padding-left:20px;"><div class="icon"><img src="img/vote.png"/></div><div class="address"><div class="long" style="width:25%;">投票</div><div class="long" style="width:75%;"><input id="votetitles" type="text" readonly="readonly"/></div></div><div class="arrow"><img src="img/arrow.png"/></div></div>');
		}
		if(tableid=="2")
		{
		buffer.append('<div id="dailytype_tool" class="position" style="padding-left:0px;"><div class="inner border-bottom" style="width:'+(swidth-20)+'px;"><div class="icon"><img src="img/edit.png"/></div><div class="address"><div class="long" style="width:25%;">日志类型</div><div class="long" style="width:75%;"><input id="dailytype" placeholder="" type="text" value="日志" readonly="readonly" val="1"/></div></div><div class="arrow"><img src="img/arrow.png"/></div></div></div>');
		buffer.append('<div class="position users" show="1" touserid="'+User.HeigID+'" todepartid="" tocomid="" style="padding-left:0px;"><div class="inner border-bottom" style="width:'+(swidth-20)+'px;"><div class="icon"><img src="img/user.png"/></div><div id="commentuser" class="address"><div class="long" style="width:25%;">批阅人</div><div class="long" style="width:75%;"><input id="traveluser" placeholder="" type="text" value="'+User.HeigName+'" readonly="readonly"/></div></div><div class="arrow"><img src="img/arrow.png"/></div></div></div>');
		buffer.append('<div class="position users border-bottom" show="2" touserid="" todepartid="" tocomid="" style="padding-left:20px;"><div class="inner" style="width:'+(swidth-20)+'px;"><div class="icon"><img src="img/client.png"/></div><div id="sendrange" class="address"><div class="long" style="width:25%;">抄送给谁</div><div class="long" style="width:75%;"><input id="traveluser" placeholder="" type="text" value="" readonly="readonly"/></div></div><div class="arrow"><img src="img/arrow.png"/></div></div></div>');
		}
		if(tableid=="3")
		{
		buffer.append('<div id="finishdate_tool" class="position finishdate" style="padding-left:0px;"><div class="inner border-bottom" style="width:'+(swidth-20)+'px;"><div class="icon"><img src="img/timer.png"/></div><div class="address"><div class="long" style="width:25%;">完成时间</div><div class="long" style="width:75%;"><input id="finishdate" placeholder="必填" type="text" value="" readonly="readonly"/></div></div><div class="arrow"><img src="img/arrow.png"/></div></div></div>');
		buffer.append('<div class="position users" show="1" touserid="" todepartid="" tocomid="" style="padding-left:0px;"><div class="inner border-bottom" style="width:'+(swidth-20)+'px;"><div class="icon"><img src="img/user.png"/></div><div id="executeuser" class="address"><div class="long" style="width:25%;">执行人</div><div class="long" style="width:75%;"><input id="traveluser" placeholder="必填" type="text" value="" readonly="readonly"/></div></div><div class="arrow"><img src="img/arrow.png"/></div></div></div>');
		buffer.append('<div class="position users border-bottom" show="2" touserid="" todepartid="" tocomid="" style="padding-left:20px;"><div class="inner" style="width:'+(swidth-20)+'px;"><div class="icon"><img src="img/client.png"/></div><div id="sendrange" class="address"><div class="long" style="width:25%;">抄送给谁</div><div class="long" style="width:75%;"><input id="traveluser" placeholder="" type="text" value="" readonly="readonly"/></div></div><div class="arrow"><img src="img/arrow.png"/></div></div></div>');
		}
		if(tableid=="4")
		{
		buffer.append('<div class="position border-bottom" style="padding-left:20px; height:auto; padding-bottom:10px;"><div class="inner" style="width:'+(swidth-20)+'px;"><div class="icon"><img src="img/user.png"/></div><div class="address">审批流程</div></div><div id="examineflow"></div></div>');
		buffer.append('<div class="position users border-bottom" show="2" touserid="" todepartid="" tocomid="" style="padding-left:20px;"><div class="inner" style="width:'+(swidth-20)+'px;"><div class="icon"><img src="img/client.png"/></div><div id="sendrange" class="address"><div class="long" style="width:25%;">抄送给谁</div><div class="long" style="width:75%;"><input id="traveluser" placeholder="" type="text" value="" readonly="readonly"/></div></div><div class="arrow"><img src="img/arrow.png"/></div></div></div>');
		}
		if(tableid=="5")
		{
		buffer.append('<div class="position" style="padding-left:0px;"><div class="inner border-bottom" style="width:'+(swidth-20)+'px;"><div class="icon"><img src="img/jiatype.png"/></div><div class="address"><div class="long" style="width:25%;">公示类别</div><div class="long" style="width:75%;"><select id="noticetype"></select></div></div><div class="arrow"><img src="img/arrow.png"/></div></div></div>');
		buffer.append('<div id="noticeenddate_tool" class="position" style="padding-left:0px;"><div class="inner border-bottom" style="width:'+(swidth-20)+'px;"><div class="icon"><img src="img/timer.png"/></div><div class="address"><div class="long" style="width:25%;">公示期</div><div class="long" style="width:75%;"><input id="noticeenddate" placeholder="" type="text" value="永久" val="-1" readonly="readonly" /></div></div><div class="arrow"><img src="img/arrow.png"/></div></div></div>');
		buffer.append('<div id="selfdate_tool" class="position hidden" style="padding-left:0px;"><div class="inner border-bottom" style="width:'+(swidth-20)+'px;"><div class="icon"><img src="img/timer.png"/></div><div class="address"><div class="long" style="width:50%;">选择自定义时间</div><div class="long" style="width:50%;"><input id="selfdate" class="" type="text" value="" placeholder="请选择" readonly="readonly"/></div></div><div class="arrow"><img src="img/arrow.png"/></div></div></div>');
		buffer.append('<div class="position users border-bottom" show="2" touserid="" todepartid="" tocomid="'+comid+'" style="padding-left:20px;"><div class="inner" style="width:'+(swidth-20)+'px;"><div class="icon"><img src="img/client.png"/></div><div id="sendrange" class="address"><div class="long" style="width:25%;">抄送给谁</div><div class="long" style="width:75%;"><input id="traveluser" placeholder="" type="text" value="全公司" readonly="readonly"/></div></div><div class="arrow"><img src="img/arrow.png"/></div></div></div>');
		}
		if(tableid=="37")
		{
		
		buffer.append('<div id="begindate_tool" class="position" style="padding-left:0px;"><div class="inner border-bottom" style="width:'+(swidth-20)+'px;"><div class="icon"><img src="img/timelong.png"/></div><div class="address"><div class="long" style="width:25%;">开始日期</div><div class="long" style="width:75%;"><input id="schedulebegindate" placeholder="必填" type="text" value="'+date.Format("yyyy-MM-dd")+'" val="'+date.Format("yyyy-MM-dd")+'" readonly="readonly" /></div></div><div class="arrow"><img src="img/arrow.png"/></div></div></div>');
		buffer.append('<div id="repeatrate_tool" class="position" style="padding-left:0px;"><div class="inner border-bottom" style="width:'+(swidth-20)+'px;"><div class="icon"><img src="img/repeat.png"/></div><div class="address"><div class="long" style="width:25%;">重复频率</div><div class="long" style="width:75%;"><input id="schedulerepeatrate" placeholder="不重复" type="text" value="不重复" readonly="readonly" /></div></div><div class="arrow"><img src="img/arrow.png"/></div></div></div>');
		buffer.append('<div id="repeatdate_tool" class="position" style="padding-left:0px; display:none;"><div class="inner border-bottom" style="width:'+(swidth-20)+'px;"><div class="icon"><img src="img/date.png"/></div><div class="address"><div class="long" style="width:25%;">重复日期</div><div class="long" style="width:75%;"><input id="schedulerepeatdate" class="" type="text" value="" val="" placeholder="请选择" readonly="readonly"/></div></div><div class="arrow"><img src="img/arrow.png"/></div></div></div>');
		buffer.append('<div id="remindtime_tool" class="position border-bottom" show="2" touserid="" todepartid="" tocomid="'+comid+'" style="padding-left:20px;"><div class="inner" style="width:'+(swidth-20)+'px;"><div class="icon"><img src="img/timer.png"/></div><div class="address"><div class="long" style="width:25%;">提醒时间</div><div class="long" style="width:75%;"><input id="scheduleremindtime" placeholder="必填" type="text" value="" readonly="readonly"/></div></div><div class="arrow"><img src="img/arrow.png"/></div></div></div>');
		}
	buffer.append('</div>');
	return buffer.toString();
};
function Check_Date1(o){
	if($("#leave_enddate").val()!="")
	{
		var diff=DateDiff("M",$("#leave_begindate").val(),$("#leave_enddate").val());
		if(diff<=0)
		{
			$(o).val("");
			plus.nativeUI.toast("结束时间必须大于开始时间");
		}else
		{
			var leave_day = parseInt(diff/1440);
			if(leave_day>20)
			{
				o.value="";
				plus.nativeUI.toast("请假时长不能大于20天");
			}else
			{
				$("#leave_day").val(leave_day);
				$("#leave_hour").val(parseInt(diff/60)%24);
				$("#leave_minute").val(parseInt(diff%60));
			}
		}
	}
};
function Check_Date2(o){
	if($("#travel_enddate").val()!="")
	{
		var diff=DateDiff("M",$("#travel_begindate").val(),$("#travel_enddate").val());
		if(diff<=0)
		{
			$("#travel_enddate").val("");
			plus.nativeUI.toast("到达时间必须大于出发时间");
		}
	}
};
function Check_Date3(o){
	if($("#overtime_enddate").val()!="")
	{
		var diff=DateDiff("M",$("#overtime_begindate").val(),$("#overtime_enddate").val());
		if(diff<=0)
		{
			$(o).val("");
			plus.nativeUI.toast("结束时间必须大于开始时间");
		}else
		{
			var leave_day = parseInt(diff/1440);
			if(leave_day>20)
			{
				o.value="";
				plus.nativeUI.toast("加班时长不能大于20天");
			}else
			{
				$("#overtime_day").val(leave_day);
				$("#overtime_hour").val(parseInt(diff/60)%24);
				$("#overtime_minute").val(parseInt(diff%60));
			}
		}
	}
};
function Publish_Submit(tableid)
{
	
					var context=get("share_context").value;
	      			var sendrange=$("#sendrange input");
	      			var coord=get("addresses");
	      			if(tableid==1)
	      			{
	      				if(sendrange.val().Trim()=="")
	      				{
	      					plus.nativeUI.toast("请选择发送对象");
				        	return;
	      				}
	      			}
	      			if(tableid==2)
	      			{
	      				if($("#commentuser input").val().Trim()=="")
	      				{
	      					plus.nativeUI.toast("请选择批阅人");
				        	return;
	      				}
	      			}
	      			if(tableid==3)
	      			{
	      				if($("#finishdate").val().Trim()=="")
	      				{
	      					plus.nativeUI.toast("请选择完成时间");
				        	return;
	      				}
	      				if($("#executeuser input").val().Trim()=="")
	      				{
	      					plus.nativeUI.toast("请选择执行人");
				        	return;
	      				}
	      			}
	      			if(tableid==4)
	      			{
	      				var examinetype=$("#examinetype").attr("val");
	      				if(examinetype==2)
	      				{
	      					if($("#leave_begindate").val().Trim()=="")
		      				{
		      					plus.nativeUI.toast("请选择开始时间");
					        	return;
		      				}
	      					if($("#leave_enddate").val().Trim()=="")
		      				{
		      					plus.nativeUI.toast("请选择结束时间");
					        	return;
		      				}
		      				if($("#leave_day").val().Trim()=="0" && $("#leave_hour").val().Trim()=="0" && $("#leave_minute").val().Trim()=="0")
		      				{
		      					plus.nativeUI.toast("请选择请假时长");
					        	return;
		      				}
	      				}
	      				if(examinetype==3)
	      				{
	      					if($("#overtime_begindate").val().Trim()=="")
		      				{
		      					plus.nativeUI.toast("请选择开始时间");
					        	return;
		      				}
	      					if($("#overtime_enddate").val().Trim()=="")
		      				{
		      					plus.nativeUI.toast("请选择结束时间");
					        	return;
		      				}
		      				if($("#overtime_day").val().Trim()=="0" && $("#overtime_hour").val().Trim()=="0" && $("#overtime_minute").val().Trim()=="0")
		      				{
		      					plus.nativeUI.toast("请选择加班时长");
					        	return;
		      				}
	      				}
	      				if(examinetype==4)
	      				{
	      					if($("#reimburse_name").val().Trim()=="")
		      				{
		      					plus.nativeUI.toast("请填写报销项");
					        	return;
		      				}
		      				if($("#reimburse_money").val().Trim()=="")
		      				{
		      					plus.nativeUI.toast("请填写报销金额");
					        	return;
		      				}
		      			}
	      				if(examinetype==5)
	      				{
	      					if($("#travel_beginplace").val().Trim()=="")
		      				{
		      					plus.nativeUI.toast("请填写出发地");
					        	return;
		      				}
		      				if($("#travel_begindate").val().Trim()=="")
		      				{
		      					plus.nativeUI.toast("请选择出发时间");
					        	return;
		      				}
		      				if($("#travel_endplace").val().Trim()=="")
		      				{
		      					plus.nativeUI.toast("请填写目的地");
					        	return;
		      				}
		      				if($("#travel_enddate").val().Trim()=="")
		      				{
		      					plus.nativeUI.toast("请选择到达时间");
					        	return;
		      				}
		      				if($("#travel_traffic").val().Trim()=="")
		      				{
		      					plus.nativeUI.toast("请选择交通工具");
					        	return;
		      				}
		      			}
	      				if(examinetype==6)
	      				{
	      					if($("#borrow_money").val().Trim()=="")
		      				{
		      					plus.nativeUI.toast("请填写借款金额");
					        	return;
		      				}
		      			}
	      				if(examinetype==7)
	      				{
	      					var customerid = $("#txt_customerid");
				            var contactid = $("#txt_contactid");
				            var mobile = $("#txt_mobile");
				            var visitaddress = $("#txt_address");
				            if (customerid.val().Trim()=="") {			                
				                plus.nativeUI.toast("请选择客户");
				        		return;
				            }
				            if (contactid.val() && contactid.val().Trim()=="") {				                
				                plus.nativeUI.toast("请选择联系人");
				        		return;
				            }
				            if (mobile.val().Trim()=="") {				                
				                plus.nativeUI.toast("请输入联系电话");
				        		return;
				            }
				            if (visitaddress.val().Trim()=="") {				                
				                plus.nativeUI.toast("请输入拜访地址");
				        		return;
				            }
	      				}
	      				
	      				if($("#examineflow .examineinfo").length==0)
			            {
			            	plus.nativeUI.alert("未设置审批流程，请联系管理员进行设置");
			            	return;
			            }
	      			}
	      			if(tableid==5)
	      			{
	      				if($("#noticetitle").val().Trim()=="")
				        {
				        	plus.nativeUI.toast("请填写公告标题");
				        	return;
				        }
				    }
	      			if(tableid==37)
	      			{
	      				var rate=$("#repeatrate_tool input").val();
	      				if($("#schedulebegindate").val().Trim()=="")
						{
							plus.nativeUI.toast("请选择开始时间");
				        	return;
						}
						if(rate=="每周" || rate=="每月" || rate=="每年"){
							if($("#schedulerepeatdate").val().Trim()=="")
							{
								plus.nativeUI.toast("请选择重复日期");
					        	return;
				        	}
						}
						if($("#scheduleremindtime").val().Trim()=="")
						{
							plus.nativeUI.toast("请选择提醒时间");
				        	return;
						}
				    }
	      			if(context=="")
		            {
		            	plus.nativeUI.toast("请"+$(".publish textarea").attr("placeholder"));
		            	return;
		            }
		            
		            if(tableid<=5 && coord.innerHTML=="正在定位...")
		            {
		            	plus.nativeUI.toast("正在定位，请稍后重试");
		            	return;
		            }
		            
		            
		        upload(function(imgs){
		        	sendrange=$("#sendrange").parent().parent();
		            var data={};
	      			data.act="Publish";
	      			data.context=context;
	      			data.touserid=sendrange.attr("touserid");
	      			data.todepartid=sendrange.attr("todepartid");
	      			data.tocomid=sendrange.attr("tocomid");
		      		if(imgs!="")
		      		{
		      			data.imgs=eval(imgs).join(",");
		      		}else
		      		{
		      			data.imgs="";
		      		}
	      			data.files="";
	      			if(tableid<=5 && coord.getAttribute("lat")!="")
	      			{
	      				data.lat=coord.getAttribute("lat");
	      				data.lng=coord.getAttribute("lng");
	      				data.address=coord.innerHTML;
	      			}
	      			
	      			
	      			if (tableid=="1") {  //分享
	      				data.model="share";
	      				if($("#vote_tool").attr("hasvote")=="true")
	      				{
	      					data.has_vote=true;
	      					
	      					if ($("#vote_enddate").val() == "0") {
					            data.vote_enddate = $("#self_enddate").val();
					        }
					        else {
					            data.vote_enddate = "";
					        }
					        data.vote_dateflag = $("#vote_enddate").val();
					        data.vote_title = $("#vote_title").val();
					        data.vote_option = CRM.ListValue($(".vote_option")) + "";
					        data.vote_maxselect = $("#vote_maxselect").val();
					        data.vote_anonymous = $("#vote_anonymous").prop("checked");
					        data.vote_seeflag = $("#vote_result").val();
					        data.vote_seeuser = $("#vote_seeuser").attr("touserid");
	      				}else
	      				{
	      					data.has_vote=false;
	      				}
	      			}
	      			if (tableid=="2") {  //日志
	      				data.model="daily";
				        data.daily_plans = $("#share_plans").val();
				        data.daily_experience = $("#share_experience").val();
				        data.daily_type = $("#dailytype").attr("val");
				        data.daily_commentuser = $("#commentuser").parent().parent().attr("touserid").TrimEnd(',');
				    }
	      			if (tableid=="3"){  //任务
	      				data.model="task";
	      				data.task_executeuser = $("#executeuser").parent().parent().attr("touserid").TrimEnd(',');
        				data.task_finishdate = $("#finishdate").val();
	      			}
	      			if(tableid=="4")  //审批
	      			{
	      				data.model="examine";
	      				data.examine_type = $("#examinetype").attr("val");
        				data.examine_user = CRM.ListVal($("#examineflow .examineinfo")) + "";
        				if(data.examine_type=="2") //请假单
        				{
        					data.leavesheet=$("#leave_type").val()+"_"+$("#leave_begindate").val()+"_"+$("#leave_enddate").val()+"_"+$("#leave_day").val()+"_"+$("#leave_hour").val()+"_"+$("#leave_minute").val();
        				}else if(data.examine_type=="3") //加班单
        				{
        					data.overtimesheet=$("#overtime_begindate").val()+"_"+$("#overtime_enddate").val()+"_"+$("#overtime_day").val()+"_"+$("#overtime_hour").val()+"_"+$("#overtime_minute").val();
        				}
        				else if(data.examine_type=="4") //报销单
        				{
        					data.reimbursesheet=$("#reimburse_name").val()+"_"+$("#reimburse_money").val()+"_"+get("share_context").value;
        				}
        				else if(data.examine_type=="5") //差旅单 
        				{
        					data.examine_personname=$("#traveluser_tool").attr("touserid").TrimEnd(',');
        					data.examine_reason = get("share_context").value;
				            data.examine_money = $("#examine_money").val();
				            data.examine_advance = $("#examine_advance").val();
				            data.travelsheet = $("#travel_beginplace").val() + "_" + $("#travel_begindate").val()  + "_" + $("#travel_endplace").val() + "_" + $("#travel_enddate").val() + "_" + $("#travel_traffic").val() + "_" + $("#travel_day").val();
				            data.context="";
        				}
        				else if(data.examine_type=="6") //借款单
        				{
        					data.examine_reason = get("share_context").value;
            				data.examine_money = $("#borrow_money").val();
            				data.context="";
        				}
        				else if(data.examine_type=="7") //外勤单
        				{
        					data.examine_customerid = $("#txt_customerid").attr("customerid");
				            data.examine_contactid = $("#txt_contactid").val();
				            data.examine_mobile = $("#txt_mobile").val();
				            data.examine_visitaddress = $("#txt_address").val();
        				}
        				
	      			}
	      			if(tableid=="5")  //公告
	      			{
	      				data.model="notice";
	      				data.notice_title = $("#noticetitle").val();
				        data.notice_type = $("#noticetype").val();
				        data.notice_period = $("#noticeenddate").attr("val");
				        data.notice_enddate = $("#selfdate").val();
	      			}
	      			if(tableid=="37")  //日程
	      			{
	      				data.model="schedule";
	      				data.schedule_begindate=$("#schedulebegindate").val();
	      				data.schedule_repeatrate=$("#schedulerepeatrate").val();
	      				data.schedule_repeatdate=$("#schedulerepeatdate").attr("val");
	      				data.schedule_remindtime=$("#scheduleremindtime").val();
	      				data.touserid="";
		      			data.todepartid="";
		      			data.tocomid="";
	      			}
	      			data.source=source;
	      			data.version=version;
	      			data.userid=userid;
	      			data.comid=comid;
	      			data.sign=GetSign(data.act);
	      			plus.nativeUI.showWaiting( "正在保存..." );
	      			CloseWaiting(20000);
	      			mui.post(index_domain, data, function(json){
	      				plus.nativeUI.closeWaiting();
	      				plus.nativeUI.toast(json.msg);
	      				if(json.state)
	      				{
	      					Clear_Form();
	      					CloseWindow(2);
	      					$("#contentlist1").html("");
	      					Data_Search(tableid);
	      					FindOAReport();
	      				}
	      			},'json');
	    		});
};

function Init_Publish(tableid)
{
	Init_ExamineDesign(1);
	if(tableid<=5){
	get("currposition").addEventListener("tap",function(){
			$("#addresses").html("正在定位...");
      		GetNewPos(function(e){
      			$("#addresses").html(e.address);
      			if(e.address!=null && e.address!="" && e.address!="null")
      			{
      				$("#addresses").attr("lat",e.latitude);
      				$("#addresses").attr("lng",e.longitude);
      			}else
      			{
      				$("#addresses").html("获取位置信息失败");
      			}
      		});
			setTimeout(function(){
				if($("#addresses").html()=="正在定位..." )
				{
					$("#addresses").html("获取位置信息失败");
				}
			},5000);
			

	});
	}
	mui(".publish").on("tap",".users",function(){
		obj10=$(this);
		OpenWindow(3,"选择发送对象","确定",function(){
				var str1="",str2="",str3="";
				touserid="";todepartid="";tocomid="";
      			var count=0;
      			mui.each(mui("#userlist input"),function(i,info){
      				if(info.checked)
      				{
      					count++;
      					str1 += info.getAttribute("val")+",";
      					touserid += info.value+",";
      				}
      			});
      			if(count>3){str1=count+"个同事,"}
      			
      			count=0;
      			mui.each(mui("#departlist .onlydepart input"),function(i,info){
      				if(info.checked)
      				{
      					count++;
      					str2 += info.getAttribute("val")+",";
      					todepartid += info.value+",";
      				}
      			});
      			if(count>3){str2=count+"个部门,"}
      			
      			mui.each(mui("#departlist .allcompany input"),function(i,info){
      				if(info.checked)
      				{
      					str3 += info.getAttribute("val")+",";
      					tocomid += info.value+",";
      				}
      			});
      			var str = str1+str2+str3;
      			if(str=="")
      			{
      				obj10.find("input").val("");
      			}else
      			{
      				obj10.find("input").val(str.substring(0,str.length-1));
      			}
      			
      			obj10.attr("touserid",touserid).attr("todepartid",todepartid).attr("tocomid",tocomid);
      			if(obj10.attr("show")=="1")
				{
					
					if(tableid=="2" && touserid.TrimEnd(",").split(",").length>1)
					{
						plus.nativeUI.toast("请选择1个批阅人");
						return;
					}
				}
      			CloseWindow();
		});
		
		$("#contentlist3").html(CheckMate_Data());
		var data = {};
		data.act = "DepartAndUser_Data";
		data.userid=userid;
		data.comid=comid;
		data.source=source;
		data.sign=GetSign(data.act);
		
		mui.getJSON(admin_domain, data, function(json) {
			Bind_CheckMate(json.data.user,json.data.depart);
			Init_CheckMate();
		});
		if(obj10.attr("show")=="1")
      	{
      		$(".selectbar").hide();
      	}else
      	{
			$(".selectbar").show();  				
      	}
		
	});
	if(tableid=="1")
	{
		$("#share_context").css("height","150");
		get("vote_tool").addEventListener("tap",function(){
			$("#divmsg5").remove();
			OpenWindow5(5,"添加投票","确定",function(){
				Sure_Vote();
			},Vote_Code());
		});
	}
	if(tableid=="2")
	{
		get("dailytype_tool").addEventListener("tap",function(){
				var buttons=[{title:"日志"},{title:"周总结"},{title:"月总结"}];
				plus.nativeUI.actionSheet( {title:"选择日志类型",cancel:"取消",buttons:buttons}, function(e){
					$("#dailytype").attr("val",e.index).val(buttons[e.index-1].title);
					$("#share_context").attr("placeholder","填写"+buttons[e.index-1].title+"内容")
					$("#context").html(buttons[e.index-1].title+"内容");
					$("#plans").html(Daily_Text(e.index)+"计划");
					$("#share_plans").attr("placeholder","填写"+Daily_Text(e.index)+"计划")
				});
		});
	}
	if(tableid=="3")
	{
		$("#share_context").css("height","150");
		/*
		get("finishdate_tool").addEventListener("tap",function(){
			plus.nativeUI.pickDate( function(e){
				var d=e.date;
				$("#finishdate").val((d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate()).ToDate());
			},function(e){
				
			});
		});
		*/
			var currYear = (new Date()).getFullYear();	
			var opt={};
			opt.date = {preset : 'date'};
			opt.datetime = {preset : 'datetime'};
			opt.time = {preset : 'time'};
			opt.default = {
				theme: 'android-ics light', //皮肤样式
		        display: 'bottom', //显示方式 
		        mode: 'scroller', //日期选择模式
				dateFormat: 'yyyy-mm-dd',
				lang: 'zh',
				showNow: true,
				nowText: "今天",
				rows: 3,
		        startYear: currYear - 10, //开始年份
		        endYear: currYear + 10 //结束年份
			};
		  	var optDateTime = $.extend(opt['datetime'], opt['default']);
		    $("#finishdate").mobiscroll(optDateTime).datetime(optDateTime);
	}
	if(tableid=="4")
	{
		get("examinetype_tool").addEventListener("tap",function(){
				var buttons=[{title:"普通审批"},{title:"请假单"},{title:"加班单"},{title:"报销单"},{title:"差旅单"},{title:"借款单"},{title:"外勤单"}];
				plus.nativeUI.actionSheet( {title:"选择报销类型",cancel:"取消",buttons:buttons}, function(e){
					if(e.index>0){
						$("#examinetype").attr("val",e.index).val(buttons[e.index-1].title);
						if(e.index==1)
						{
							$("#leavesheet,#overtimesheet,#reimbursesheet,#travelsheet,#borrowsheet,#outsidesheet").addClass("hidden");
							$(".publish textarea").attr("placeholder","填写审批内容");
						}else if(e.index==2)
						{
							$("#leavesheet,#overtimesheet,#reimbursesheet,#travelsheet,#borrowsheet,#outsidesheet").addClass("hidden");
							$("#leavesheet").removeClass("hidden");
							$(".publish textarea").attr("placeholder","填写请假原因");
						}else if(e.index==3)
						{
							$("#leavesheet,#overtimesheet,#reimbursesheet,#travelsheet,#borrowsheet,#outsidesheet").addClass("hidden");
							$("#overtimesheet").removeClass("hidden");
							$(".publish textarea").attr("placeholder","填写加班原因");
						}
						else if(e.index==4)
						{
							$("#leavesheet,#overtimesheet,#reimbursesheet,#travelsheet,#borrowsheet,#outsidesheet").addClass("hidden");
							$("#reimbursesheet").removeClass("hidden");
							$(".publish textarea").attr("placeholder","填写报销备注");
						}else if(e.index==5)
						{
							$("#leavesheet,#overtimesheet,#reimbursesheet,#travelsheet,#borrowsheet,#outsidesheet").addClass("hidden");
							$("#travelsheet").removeClass("hidden");
							$(".publish textarea").attr("placeholder","填写出差事由");
						}else if(e.index==6)
						{
							$("#leavesheet,#overtimesheet,#reimbursesheet,#travelsheet,#borrowsheet,#outsidesheet").addClass("hidden");
							$("#borrowsheet").removeClass("hidden");
							$(".publish textarea").attr("placeholder","填写借款事由");
						}else if(e.index==7)
						{
							$("#leavesheet,#overtimesheet,#reimbursesheet,#travelsheet,#borrowsheet,#outsidesheet").addClass("hidden");
							$("#outsidesheet").removeClass("hidden");
							$(".publish textarea").attr("placeholder","填写拜访内容");
						}
						Init_ExamineDesign(e.index);
					}
				});
		});
		/*
		get("travelbegindate_tool").addEventListener("tap",function(){
			plus.nativeUI.pickDate( function(e){
				var d=e.date;
				$("#travelbegindate_tool input").val((d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate()).ToDate());
			},function(e){
				
			});
		});
		get("travelenddate_tool").addEventListener("tap",function(){
			plus.nativeUI.pickDate( function(e){
				var d=e.date;
				$("#travelenddate_tool input").val((d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate()).ToDate());
			},function(e){
				
			});
		});
		*/
		return;
		get("traveltraffic_tool").addEventListener("tap",function(){
			var buttons=[{title:"高铁"},{title:"动车"},{title:"普快"},{title:"飞机"},{title:"大巴车"},{title:"出租车"},{title:"其他"}];
				plus.nativeUI.actionSheet( {title:"选择交通工具",cancel:"取消",buttons:buttons}, function(e){
					$("#traveltraffic_tool input").val(buttons[e.index-1].title);
			});
		});
		get("leavetype_tool").addEventListener("tap",function(){
			var buttons=[{title:"事假"},{title:"病假"},{title:"调休"},{title:"年休假"},{title:"婚假"},{title:"生育假"},{title:"丧假"},{title:"加班"},{title:"其他"}];
				plus.nativeUI.actionSheet( {title:"选择请假类型",cancel:"取消",buttons:buttons}, function(e){
					$("#leave_type").attr("val",e.index).val(buttons[e.index-1].title);
			});
		});
		get("customer_tool").addEventListener("tap",function(){
			myScroll3 = OpenScroll2(4,"选择客户","",function(pageindex){
										Receive_CustomerSelect(pageindex);
								},function(){
									
								},CustomerSelect_Code(),70);
								//$("#contentlist2").append(Publish_Code());
								Receive_CustomerSelect(1);
								get("find2").addEventListener("tap",function(){
				      				$("#searchicon2").hide();
	      							$("#searchicons2").show();
	      							$("#keyword2").attr("placeholder","客户名称(支持拼音)，地址");
			    					if($("keyword2").val()!="")
			    					{
			    						//WorkMate_Search();
			    					}
				      			});
		});
		/*
		mui(".publish").on("tap",".date",function(){
			obj=this;
			plus.nativeUI.pickDate( function(e){
				var d=e.date;
				$(obj).find("input").val(d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate());
			},function(e){
				console.log( "未选择日期："+e.message );
			});
		});
		*/
		var currYear = (new Date()).getFullYear();	
			var opt={};
			opt.date = {preset : 'date'};
			opt.datetime = {preset : 'datetime'};
			opt.time = {preset : 'time'};
			opt.default = {
				theme: 'android-ics light', //皮肤样式
		        display: 'bottom', //显示方式 
		        mode: 'scroller', //日期选择模式
				dateFormat: 'yyyy-mm-dd',
				lang: 'zh',
				showNow: true,
				nowText: "今天",
				rows: 3,
		        startYear: currYear - 10, //开始年份
		        endYear: currYear + 10 //结束年份
			};
		  	var optDateTime = $.extend(opt['datetime'], opt['default']);
		    $("#leave_begindate,#leave_enddate,#overtime_begindate,#overtime_enddate,#travel_begindate,#travel_enddate").mobiscroll(optDateTime).datetime(optDateTime);
		    var today = new Date(GetDateStr(1).replace(/-/g, "/"));
		    var tomorrow = new Date(GetDateStr(2).replace(/-/g, "/"));
		    $("#leave_begindate").scroller('setDate', today, true);
		    $("#leave_enddate").scroller('setDate', tomorrow, true);
		    $("#overtime_begindate").scroller('setDate', new Date(new Date().Format("yyyy-MM-dd 08:00").replace(/-/g, "/")), true);
		    $("#overtime_enddate").scroller('setDate', new Date(new Date().Format("yyyy-MM-dd 12:00").replace(/-/g, "/")), true);
	}
	if(tableid==5)
	{
		get("noticeenddate_tool").addEventListener("tap",function(){
				var buttons=[{title:"永久",value:"-1"},{title:"3天",value:"3"},{title:"5天",value:"5"},{title:"1周",value:"7"},{title:"2周",value:"14"},{title:"自定义",value:"0"}];
				plus.nativeUI.actionSheet( {title:"选择公示期",cancel:"取消",buttons:buttons}, function(e){
					$("#noticeenddate").attr("val",buttons[e.index-1].value).val(buttons[e.index-1].title);
					if(buttons[e.index-1].value=="0")
					{
						$("#selfdate_tool").removeClass("hidden");
					}
					else
					{
						$("#selfdate_tool").addClass("hidden");
					}
				});
		});
		get("selfdate_tool").addEventListener("tap",function(){
			/*
			obj=this;
			plus.nativeUI.pickDate( function(e){
				var d=e.date;
				$(obj).find("input").val(d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate());
			},function(e){
				console.log( "未选择日期："+e.message );
			});
			*/
			var currYear = (new Date()).getFullYear();	
			var opt={};
			opt.date = {preset : 'date'};
			opt.datetime = {preset : 'datetime'};
			opt.time = {preset : 'time'};
			opt.default = {
				theme: 'android-ics light', //皮肤样式
		        display: 'bottom', //显示方式 
		        mode: 'scroller', //日期选择模式
				dateFormat: 'yyyy-mm-dd',
				lang: 'zh',
				showNow: true,
				nowText: "今天",
				rows: 3,
		        startYear: currYear - 10, //开始年份
		        endYear: currYear + 10 //结束年份
			};
		  	var optDateTime = $.extend(opt['datetime'], opt['default']);
		    $("#selfdate").mobiscroll(optDateTime).datetime(optDateTime);
		});
		Init_NoticeType();
	}
	if(tableid==37)
	{
		get("begindate_tool").addEventListener("tap",function(){
			obj10=this;
			var t=new Date();
			if($(this).find("input").val()!="")
			{
				var year_month_day=$(this).find("input").val().split("-");
				t.setFullYear(year_month_day[0]);
				t.setMonth(year_month_day[1]-1);
				t.setDate(year_month_day[2]);
			}
			plus.nativeUI.pickDate( function(e){
				var d=e.date;
				$(obj10).find("input").val((d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate()).ToDate());
			},function(e){
				console.log( "未选择日期："+e.message );
			},{date:t});
		});
		
		get("repeatrate_tool").addEventListener("tap",function(){
			var buttons=[{title:"不重复"},{title:"每天"},{title:"每周"},{title:"每月"},{title:"每年"}];
			plus.nativeUI.actionSheet( {title:"选择重复频率",cancel:"取消",buttons:buttons}, function(e){
				$("#schedulerepeatdate").val("").attr("val","").attr("placeholder","请选择");
				$("#repeatrate_tool input").val(buttons[e.index-1].title);
				if(e.index<=2)
				{
					$("#repeatdate_tool").hide(200);
				}else
				{
					$("#repeatdate_tool").show(200);
				}
			});
		});
		get("repeatdate_tool").addEventListener("tap",function(){
			var html='';
			var rate=$("#repeatrate_tool input").val();
			if(rate=="每周"){
				html='<div class="repeattitle"><a id="repeatsure">确定</a></div><div class="repeatpanel"><div class="square ui-border" val="1">周一</div><div class="square ui-border" val="2">周二</div><div class="square ui-border" val="3">周三</div><div class="square ui-border" val="4">周四</div><div class="square ui-border" val="5">周五</div><div class="square ui-border" val="6">周六</div><div class="square ui-border" val="7">周日</div></div>';
				OpenMeng4(html);
			}else if(rate=="每月"){
				html='<div class="repeattitle"><a id="repeatsure">确定</a></div><div class="repeatpanel"><div class="square ui-border" val="1">1</div><div class="square ui-border" val="2">2</div><div class="square ui-border" val="3">3</div><div class="square ui-border" val="4">4</div><div class="square ui-border" val="5">5</div><div class="square ui-border" val="6">6</div><div class="square ui-border" val="7">7</div><div class="square ui-border" val="8">8</div><div class="square ui-border" val="9">9</div><div class="square ui-border" val="10">10</div><div class="square ui-border" val="11">11</div><div class="square ui-border" val="12">12</div><div class="square ui-border" val="13">13</div><div class="square ui-border" val="14">14</div><div class="square ui-border" val="15">15</div><div class="square ui-border" val="16">16</div><div class="square ui-border" val="17">17</div><div class="square ui-border" val="18">18</div><div class="square ui-border" val="19">19</div><div class="square ui-border" val="20">20</div><div class="square ui-border" val="21">21</div><div class="square ui-border" val="22">22</div><div class="square ui-border" val="23">23</div><div class="square ui-border" val="24">24</div><div class="square ui-border" val="25">25</div><div class="square ui-border" val="26">26</div><div class="square ui-border" val="27">27</div><div class="square ui-border" val="28">28</div><div class="square ui-border" val="29">29</div><div class="square ui-border" val="30">30</div><div class="square ui-border" val="31" style="width:27.125%">最后一天</div></div>';
				OpenMeng4(html);
			}else if(rate=="每年")
			{
				obj10=this;
				var t=new Date();
				if($(this).find("input").val()!="")
				{
					var year_month_day=$(this).find("input").val().replace("日","").split("月");
					t.setFullYear(t.getFullYear());
					t.setMonth(year_month_day[0]-1);
					t.setDate(year_month_day[1]);
				}
				plus.nativeUI.pickDate( function(e){
					var d=e.date;
					var month=d.getMonth()+1;
					$(obj10).find("input").val((d.getMonth()+1)+"月"+d.getDate()+"日").attr("val", (month<10?("0"+month):month)+"-"+d.getDate());
				},function(e){
					console.log( "未选择日期："+e.message );
				},{date:t});
			}
			
		});
		get("remindtime_tool").addEventListener("tap",function(){
			obj=this;
			var select_time = $(obj).find("input").val();
			if(select_time==""){select_time="12:00";}
			var hour_minute=select_time.split(":");
			var t=new Date();
			if(select_time!="")
			{
				t.setHours(parseInt(hour_minute[0]), parseInt(hour_minute[1]));
			}
			plus.nativeUI.pickTime( function(e){
				var d=e.date;
				var hour=d.getHours();
				var minute=d.getMinutes();
				$(obj).find("input").val((hour<10?"0"+hour:hour)+":"+(minute<10?"0"+minute:minute));
			},function(e){
				console.log( "未选择时间："+e.message );
			},{time:t});
		});
	}
	get("addphoto").addEventListener('tap', function(event) {
				//get("share_context").blur();
						var btnArray = [{
							title: "拍照"
						}, {
							title: "从相册选择"
						}];
						plus.nativeUI.actionSheet({
							title: "选择照片",
							cancel: "取消",
							buttons: btnArray
						}, function(e) {
							var index = e.index;
							switch (index) {
								case 0:
									break; 
								case 1:
									var cmr = plus.camera.getCamera();
									cmr.captureImage(function(path) {
										at_count=0;
										ResizeImg("file://" + plus.io.convertLocalFileSystemURL(path),1);
										Init_ImgPreview();
									}, function(err) {});
									break;
								case 2:
									
									plus.gallery.pick(function(e) {
										at_count=0;
										for(var i in e.files){
									    	ResizeImg(e.files[i],e.files.length);
									    	Init_ImgPreview();
								    	}
									}, function(err) {}, {filter:"image",multiple:true,maximum:9});
									break;
							}
						}); 
					}, false);
};

function Init_ImgPreview()
{
	mui("#img_src").off("tap",".up_img");
	mui("#img_src").on("tap",".up_img",function(){
		SeePhoto(this);
	});
};

function Daily_Text(dailytype){
	if (dailytype == 1) { return "明日"; }
    else if (dailytype == 2) { return "下周"; }
    else if (dailytype == 3) { return "下月"; }
}

function Init_NoticeType() {
    var data = {};
    data.userid=userid;
	data.comid=comid;
	data.source=source;
    data.act = "Find_NoticeType";
    data.sign=GetSign(data.act);
	
	mui.getJSON(admin_domain, data, function(json) {
        var str = "";
        $.each(json.data, function (i, info) {
            str += "<option value='" + info.ID + "'>" + info.Name + "</option>";
        });
        $("#noticetype").html(str);
    });
};

function upload(fun){
      		if($("#img_src img[class!='add']").length>0)
      		{
				var wt=plus.nativeUI.showWaiting("正在上传图片...");
				CloseWaiting(20000);
				var task=plus.uploader.createUpload(upload_domain,
					{method:"POST"},
					function(t,status){ //上传完成
						if(status==200){
							wt.close();
							fun(t.responseText);
						}else{
							wt.close();
						}
					}
				);
				var date = new Date();
				task.addData("userid",userid);
				task.addData("comid",comid);
				task.addData("handle","upload_img");
				task.addData("random",date.Format("hhmmss"));
				$("#img_src img[class!='add']").each(function(){
					task.addFile(this.src,{key:this.src});
				});
				
				task.start();
			}
      		else{
      			fun("");
      		}
	};
	
var at_count=0; //加载到第几张图片
//压缩图片，另外，安卓手机显示图片调用这个方法，否则超过3张界面会卡死
function ResizeImg(url,count){
	var image = new Image();
	image.src=url;
	var orientation=null;
	var rotate=0;
	image.onload=function(){ //图片加载完成
    //获取原始照片方向信息
    EXIF.getData(image,function () {
    	var height=1000*image.height/image.width;
        orientation = EXIF.getTag(this, "Orientation");
        if(orientation==1){//0°
            rotate=0;
            height=1000*image.height/image.width;
        }else if(orientation==6){//顺时针90°
            rotate=90;
            height=1000*image.width/image.height;
        }else if(orientation==8){//逆时针90°/顺时针270°
            rotate=270;
            height=1000*image.width/image.height;
        }else if(orientation==3){//180°
            rotate=180;
            height=1000*image.height/image.width;
        }
        var img=url.substring(url.lastIndexOf("/")+1,url.length).split(".")[0];
		plus.zip.compressImage(
					    {
					      src: url,
					      dst: '_doc/'+img+'_o.jpg',
					      overwrite: true,
					      width: '1000px', //这里指定了宽度，同样可以修改
					      height: parseInt(height)+'px',
					      format: 'jpg',
					      quality: 50  //图片质量不再修改，以免失真 
					    },
					    function(e) {
					      
					      $("<img class='up_img' src='" + e.target +"' width='"+(swidth-70)/4+"' height='"+(swidth-70)/4+"'/>").insertBefore("#addphoto");
					      at_count++;
                            $(".imgload").html("加载"+parseInt(parseFloat(at_count)/count*100)+"%");
                            if(at_count==count){
                            	$(".imgload").hide();
                            }
					    },
					    function(err) {
					      plus.nativeUI.alert('未知错误！',function() {
					        mui.back();
					      });
					    }
		);
    });

    };	
};

function Context_Change(o,id,tableid){
	if(tableid=="2" )
	{
		$("#"+id).show(200);
		if($(o).val()=="")
		{
			$("#"+id).hide(200);
		}
	}
};

function Init_ExamineDesign(type) {
    var str = "";
    var data = {};
    data.type = type;
    data.userid=userid;
	data.comid=comid;
	data.source=source;
    data.act = "Init_ExamineDesign";
    data.sign=GetSign(data.act);
	
	mui.getJSON(index_domain, data, function(json) {
		var str="";
		$.each(json.data, function (i, info) {
			str+='<div class="examineinfo" val="'+info.ExamineUser+'"><div class="headimg"><img src="'+info.HeadImg+'"/></div><div class="realname">'+info.ExamineName+'</div></div>';
			str+='<div class="line" style="padding-top:5px;">...</div>';
		});
		if(json.data.length==0)
		{
			str+='<div class="noset">未设置</div>';
			str+='<div class="line" style="padding-top:5px;">...</div>';
		}
		str+='<div class="success">完成</div>';
		$("#examineflow").html(str);
	});
};